<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Class-私有属性-ES11</title>
</head>

<body>
  <script>
    class Person {
      // 共有属性
      name;
      // 私有属性
      #age;
      #job;

      constructor(name, age, job) {
        this.name = name;
        this.#age = age;
        this.#job = job;
      }

      intro() {
        console.log(this.name);
        console.log(this.#age);
        console.log(this.#job);
      }
    }

    let girl = new Person('Li', 28, "前端工程师");

    console.log(girl);
    // console.log(girl.name);
    // console.log(girl.#age);   // 报错：Uncaught SyntaxError: Private field '#age' must be declared in an enclosing class

    girl.intro();
  </script>
</body>

</html>